// Dialog box che appaiono
$(document).ready(function() {	

	$('a.modal').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	});
    
    $('a[href=#dialog_contattaci]').click(function(e) {
        $('.formError').show();
    });
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
		$('.formError').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
		$('.formError').hide();
	});			
	
});


// Mp3 player

$(document).ready(function(){
    // Usa un timeout per segnalare al browser
    // che il caricamento della pagina è terminato
    setTimeout(function() {
      $("#jquery_jplayer_1").jPlayer({
          ready: function () {
              $(this).jPlayer("setMedia", {
                  //mp3: "http://www.jplayer.org/audio/mp3/Miaow-07-Bubble.mp3"
                  //mp3: "flash/Twisted_Nerve.mp3"
				mp3: "http://megahitrecords.com/audio/ATL0612/ATL0612CD1Track1.mp3"
              }).jPlayer("pause");
          },
          ended: function (event) {
              $(this).jPlayer("stop");
          },
          swfPath: "js",
          supplied: "mp3"
      });
    }, 1000);
});
 //Carrello
	$('#cart_element_1_close').click(function() {
        $('#cart_element_1_sx').slideUp();
        $('#cart_element_1_dx').slideUp();
    });
    
    $('#cart_element_1_plus').click(function() {
        $('.boxgrid.captionfull').mouseover();
        var num_biglietti = parseInt($('#num_biglietti_1').text());
        num_biglietti = num_biglietti + 1;
        $('#num_biglietti_1').text(num_biglietti);
        var lett = "i";
        if ( num_biglietti == 1 ) 
            lett = "o";
        $('#biglietto_i_1').text(lett);
    });
    
    $('#cart_element_1_min').click(function() {
        $('.boxgrid.captionfull').mouseover();
        var num_biglietti = parseInt($('#num_biglietti_1').text());
        if (num_biglietti > 0) {
            num_biglietti = num_biglietti - 1;
            $('#num_biglietti_1').text(num_biglietti);
            var lett = "i";
            if ( num_biglietti == 1 ) 
                lett = "o";
            $('#biglietto_i_1').text(lett);
        }
    });

// Pannello a sinistra	
$(document).ready(function(){
	$(".trigger").click(function(){
		$(".panel-left").toggle("fast");
		$(this).toggleClass("active");
		return false;
	});
});
